package com.demo.house.service.impl;

import com.demo.house.dao.QuestionDao;
import com.demo.house.dao.UserDao;
import com.demo.house.entity.Question;
import com.demo.house.entity.User;
import com.demo.house.service.QuestionService;
import com.demo.house.vo.request.RequestQuestionVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionDao questionDao;

    @Autowired
    private UserDao userDao;


    /**
     * 查询所有问题
     * @return
     */
    @Override
    public List<Question>queryAll(Integer houseSourceId) {
        return questionDao.list(houseSourceId);
    }



    /**
     * 新增问题
     * @param requestQuestionVo 实例对象
     * @return
     */
    @Override
    public int insert(RequestQuestionVo requestQuestionVo) {
        Question question = new Question();
        question.setCreateTime(new Date());
        BeanUtils.copyProperties(requestQuestionVo,question);
        return questionDao.insert(question);
    }


}
